﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using Microhard.Permission.Models;
using Microhard.Framework.MVCHelper;
using Microhard.Permission.Interface;
using Microsoft.Practices.Unity;
using FluentValidation.Mvc;
using Microhard.WebUI.Models;
using Microhard.Permission.MVCFilter;

namespace Microhard.WebUI.Areas.Admin.Controllers
{
    public class OperationController : MicroHardBaseController<Operation>
    {
        private IOperation _operation = null;
        [Dependency]
        public IOperation operation
        {
            set
            {
                base._repository = value;
                _operation = value;
            }
            get
            {
                return _operation;
            }
        }

        [MVCFilterAtrForLogon()]
        [MVCFilterAtrForResourcePermission(OperationKeyName="Index")]
        public ActionResult GetSelectList(AttriubteOfSelectList ctrAttr)
        {
            var roles = _operation.Query(null);
            ctrAttr.Data = roles.Select(r => new SelectData
            {
                ID = r.OperationID.ToString(),
                Name = r.Name
            }).ToList();
            return View("SelectList", ctrAttr);
        }
    }
}
